import random
import numpy as np
import torch
import os

def seed_all(seed_value):
    random.seed(seed_value) # Python
    np.random.seed(seed_value) # cpu vars
    torch.manual_seed(seed_value) # cpu vars
    os.environ['PYTHONHASHSEED'] = str(seed_value)
    
    if torch.cuda.is_available(): 
        torch.cuda.manual_seed(seed_value)
        torch.cuda.manual_seed_all(seed_value) # gpu vars
        torch.backends.cudnn.enabled = True
        torch.backends.cudnn.deterministic = True  #needed
        torch.backends.cudnn.benchmark = True

seed_all(42)

import trainer
import os
import time
from run import cfg
from utils.get_args import parse_option

if __name__ == "__main__":
   cfg = parse_option()

   train = trainer.Trainer(cfg)

   if cfg.train:
      train.train()
   else:
      train.test()
